MaxSize = 100


class CSqQueue:
    def __init__(self) -> None:
        self.data = [None] * MaxSize
        self.front = 0
        self.rear = 0

    def empty(self):
        """判断队列是否为空"""
        return self.front == self.rear

    def push(self, e):
        """元素e进队函数"""
        assert (self.rear + 1) % MaxSize != self.front  # 检测队满
        self.rear = (self.rear + 1) % MaxSize  # rear循环前进
        self.data[self.rear] = e

    def pop(self):
        assert not self.empty()
        self.front = (self.front + 1) % MaxSize  # front循环前进
        return self.data[self.front]

    def gethead(self):
        """取出队头元素"""
        assert not self.empty()
        head = (self.front + 1) % MaxSize
        return self.data[head]

    def size(self):
        return ((self.rear - self.front + MaxSize) % MaxSize)
